<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
    <title>上传控件 - 最好用的.net权限工作流框架|.net core快速开发框架|.net core权限管理|.net core工作流</title>
    <meta name="Keywords" content="Qs.net,.net开源工作流,.NET开源权限管理">
    <meta name="Description" content="最好用的.net开源工作流框架,最好用的.NET开源权限管理框架">
    <link rel="stylesheet" href="bootstrap/css/bootstrap.css">
    <!--[if lte IE 6]>
    <link rel="stylesheet" type="text/css" href="bootstrap/css/bootstrap-ie6.css">
    <![endif]-->
    <!--[if lte IE 7]>
    <link rel="stylesheet" type="text/css" href="bootstrap/css/ie.css">
    <![endif]-->
    <link rel="stylesheet" href="leipi.style.css">
    <script type="text/javascript" src="../dialogs/internal.js"></script>
    <script type="text/javascript">
        /* Thank you by
        http://www.alt-tag.com/blog/2006/02/ie-dom-bugs/ */
        function createElement(type, name) {
            var element = null
            try {
                element = document.createElement('<' + type + ' name="' + name + '">')
            } catch (e) {}
            if (element == null) {
                element = document.createElement(type)
                element.name = name
            }
            return element
        }
    </script>
</head>

<body>
    <div class="content">
        <table class="table table-bordered table-striped table-hover">
            <tr>
                <th><span>控件名称</span><span class="label label-important">*</span></th>
                <th><span>显示名称</span> </th>
            </tr>
            <tr>
                <td><input type="text" id="orgname" placeholder="必填项"></td>
                <td><input type="text" id="orgvalue" placeholder="无则不填"></td>
            </tr>
            <tr>
                <th><span>对齐方式</span> </th>
                <th><span>&nbsp;&nbsp;&nbsp;&nbsp;长&nbsp;&nbsp;X&nbsp;&nbsp;宽</span> </th>

            </tr>
            <tr>

                <td>
                    <select id="orgalign">
            <option value="left">左对齐</option>
            <option value="center">居中对齐</option>
            <option value="right">右对齐</option>
          </select>
                </td>
                <td>
                    <input id="orgwidth" type="text" value="150" class="input-small span1" placeholder="auto" /> X
                    <input id="orgheight" type="text" value="" class="input-small span1" placeholder="auto" /> px

                </td>
            </tr>

        </table>
        <div id="node">
            <iframe src="/ueditor/formdesign/el-input.html" leipiplugins="element" style="height:100px;"></iframe>
        </div>
    </div>
    <script type="text/javascript">
        function getParameter(paraStr, url) {
            var result = ''
            var str = '&' + url.split('?')[1]
            var paraName = paraStr + '='

            if (str.indexOf('&' + paraName) != -1) {
                if (str.substring(str.indexOf(paraName), str.length).indexOf('&') != -1) {
                    var TmpStr = str.substring(str.indexOf(paraName), str.length)
                    result = TmpStr.substr(TmpStr.indexOf(paraName), TmpStr.indexOf('&') - TmpStr.indexOf(paraName))
                } else {
                    result = str.substring(paraName.length + 1, str.length)
                }
            } else {
                result = '无此参数'
            }
            return (result.replace('?', ''))
        }

        var oNode = null
        var thePlugins = 'element'
        window.onload = function() {
            if (UE.plugins[thePlugins].editdom) {
                oNode = UE.plugins[thePlugins].editdom
                    // var gValue = ''
                    // if (oNode.getAttribute('value')) {
                    //   gValue = oNode.getAttribute('value').replace(/&quot;/g, '"')
                    // }
                    // var gTitle = oNode.getAttribute('title').replace(/&quot;/g, '"'),
                    //   gAlign = oNode.getAttribute('orgalign'),
                    //   gWidth = oNode.getAttribute('orgwidth'),
                    //   gHeight = oNode.getAttribute('orgheight')
                    // gValue = gValue == null ? '' : gValue
                    // gTitle = gTitle == null ? '' : gTitle
                var src = oNode.getAttribute('src')
                var search = decodeURI(decodeURI(src))
                var r = getParameter('info', search)
                console.log(r)
                if (r != null) {
                    var infoObj = JSON.parse(r)
                    $G('orgvalue').value = infoObj.gValue
                    $G('orgname').value = infoObj.gTitle
                    $G('orgwidth').value = infoObj.gWidth
                    $G('orgheight').value = infoObj.gHeight
                    $G('orgalign').value = infoObj.gAlign
                }
            }
        }
        dialog.oncancel = function() {
            if (UE.plugins[thePlugins].editdom) {
                delete UE.plugins[thePlugins].editdom
            }
        }
        dialog.onok = function() {
            if ($G('orgname').value == '') {
                alert('请输入控件名称')
                return false
            }
            var gValue = $G('orgvalue').value.replace(/\"/g, '&quot;'),
                gTitle = $G('orgname').value.replace(/\"/g, '&quot;'),
                gAlign = $G('orgalign').value,
                gWidth = $G('orgwidth').value,
                gHeight = $G('orgheight').value

            if (!oNode) {
                try {
                    oNode = createElement('input', 'leipiNewField')
                    oNode.setAttribute('type', 'file')
                    oNode.setAttribute('title', gTitle)
                    oNode.setAttribute('value', gValue)
                    oNode.setAttribute('name', 'leipiNewField')
                    oNode.setAttribute('leipiPlugins', thePlugins)
                    if (gAlign != '') {
                        // style += 'text-align:' + gAlign + ';';
                        oNode.style.textAlign = gAlign
                        oNode.setAttribute('orgalign', gAlign)
                    }
                    if (gWidth != '') {
                        oNode.style.width = gWidth + 'px'
                            // style += 'width:' + gWidth + 'px;';
                        oNode.setAttribute('orgwidth', gWidth)
                    }
                    if (gHeight != '') {
                        oNode.style.height = gHeight + 'px'
                            // style += 'height:' + gHeight + 'px;';
                        oNode.setAttribute('orgheight', gHeight)
                    }
                    // oNode.setAttribute('style',style );
                    // oNode.style.cssText=style;//ie7
                    var pararm = {
                        gValue: encodeURI(gValue),
                        gTitle: encodeURI(gTitle),
                        gAlign: encodeURI(gAlign),
                        gWidth: encodeURI(gWidth),
                        gHeight: encodeURI(gWidth)
                    }
                    var pararmStr = encodeURI(JSON.stringify(pararm), 'utf-8')
                    var iframeSrc = '/ueditor/formdesign/el-input.html?info=' + pararmStr
                    document.querySelector('iframe').setAttribute('src', iframeSrc)
                    var html = document.getElementById('node').innerHTML
                    editor.execCommand('insertHtml', html)
                        // editor.execCommand('insertHtml', oNode.outerHTML)
                } catch (e) {
                    try {
                        editor.execCommand('error')
                    } catch (e) {
                        alert('控件异常')
                    }
                    return false
                }
            } else {
                oNode.setAttribute('title', gTitle)
                oNode.setAttribute('value', $G('orgvalue').value)
                if (gAlign != '') {
                    oNode.style.textAlign = gAlign
                    oNode.setAttribute('orgalign', gAlign)
                } else {
                    oNode.setAttribute('orgalign', '')
                }
                if (gWidth != '') {
                    oNode.style.width = gWidth + 'px'
                    oNode.setAttribute('orgwidth', gWidth)
                } else {
                    oNode.style.width = ''
                    oNode.setAttribute('orgwidth', '')
                }
                if (gHeight != '') {
                    oNode.style.height = gHeight + 'px'
                    oNode.setAttribute('orgheight', gHeight)
                } else {
                    oNode.style.height = ''
                    oNode.setAttribute('orgheight', '')
                }
                delete UE.plugins[thePlugins].editdom
            }
        }
    </script>
</body>

</html>